package org.sample.springbootredis.client;

import java.util.List;

import org.sample.springbootredis.client.model.DateDTO;
import org.sample.springbootredis.client.model.UserDTO;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value = "userService", url = "http://localhost:8089/user")
public interface DatabaseUserClient {

	@GetMapping("/all")
	public List<UserDTO> findAll();

	@GetMapping("/{id}")
	public UserDTO findById(@PathVariable("id") Long id);

	@GetMapping
	public UserDTO findByUserName(@RequestParam("username") String userName);

	@PostMapping
	public UserDTO create(@RequestBody UserDTO userDTO);

	@PostMapping("/rollback")
	public UserDTO saveWithRollback(@RequestBody UserDTO userDTO);

	@PostMapping("/norollback")
	public UserDTO saveWithoutRollback(@RequestBody UserDTO userDTO);

	@PutMapping("/{id}")
	public UserDTO updateById(@PathVariable("id") Long id, @RequestBody UserDTO userDTO);

	@PutMapping
	public UserDTO updateByName(@RequestParam("username") String userName, @RequestBody UserDTO userDTO);

	@DeleteMapping("/{id}")
	public void deleteById(@PathVariable("id") Long id);

	@DeleteMapping
	public void deleteByName(@RequestParam("username") String userName);

	@PostMapping("/date")
	public List<UserDTO> findByCreatedDate(@RequestBody DateDTO dateDTO);

}
